package com.wuba.rxjavademo.tzx.create;

import com.wuba.rxjavademo.tzx.common.Base;
import com.wuba.rxjavademo.tzx.common.SimpleSubscriber;

import rx.Observable;

/**
 * Created by tanzhenxing
 * Date: 2016/6/24.
 * Description:
 * range:从一个指定的数字X开始发射N个数字.range(x,n);
 */
public class RxRange extends Base {
    public static void main(String [] args) {
        RxRange rxRunge = new RxRange();
        rxRunge.run();
    }

    @Override
    public void run() {
        Observable<Integer> observable = Observable.range(3,1);
        observable
                .subscribe(new SimpleSubscriber<Integer>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(Integer integer) {
                        super.onNext(integer);
                        print(String.valueOf(integer));
                    }
                });
        observable
                .subscribe(new SimpleSubscriber<Integer>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(Integer integer) {
                        super.onNext(integer);
                        print(String.valueOf(integer));
                    }
                });
    }
}
